function [ ] = problem2(img)
close all

[M, N, ~] = size(img);
skel = zeros(M,N);

%Binarization
bw = blockBinarization(img, 1);

%Ponemos 1s en el borde
bw(1,:) = 1;
bw(M,:) = 1;
bw(:,1) = 1;
bw(:,N) = 1;

%Labelization
[labs, L] = bwlabel(1-bw,8);
figure('name','labels'); imshow(label2rgb(labs));

%Compute MAT for each component
mask = cell(L,1);
for i = 1:1:L
    mask{i} = (1-bw) .* (labs == i);
    figure('name','mask'); imshow(mask{i}, []);
    skel = skel | mat(1-mask{i});
end

figure('name','skel'); imshow(skel, []);

end